ARCH := x86

include $(ARCH)/Makefile
include libc/Makefile

OBJS += CPlusPlus.o \
	FrameAllocator.o \
	Kernel.o \
	Multiboot.o \
	Proc.o \
	Scheduler.o

INCLUDE := -I./include -I./include/libc -I./include/$(ARCH)
CFLAGS := $(INCLUDE) -Wall -nostdlib -nostdinc -fno-builtin -nostartfiles -nodefaultlibs -D__$(ARCH)__
CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti

all: $(OBJS)
	@echo " LD		kernel"
	@ld -T $(ARCH)/linker $(OBJS) -o kernel
	@mv kernel iso/boot
	@echo " MKISOFS	kernel.iso"
	@mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \
		4 -boot-info-table -o kernel.iso iso 2> /dev/null

.c.o:
	@echo " GCC		"$@
	@gcc -o $@ -c $? $(CFLAGS)

.cpp.o:
	@echo " G++		"$@
	@g++ -o $@ -c $? $(CXXFLAGS)

.s.o:
	@echo " ASM		"$@
	@nasm -f elf -o $@ $?

clean:
	@rm -f $(OBJS)
